package GoFile

import (
	"fmt"
	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
	"m/Global"
	"m/model"
)

func RouterInit(router *gin.Engine)  {
	router.Use(cors.Default())

	router.GET("/find/FindStudent", GetList)
}

func GetList(c *gin.Context) {
	var student model.Student
	err := Global.Db.Take(&student).Error
	if err != nil {
		fmt.Println("查询错误！！！")
		return
	}
	//fmt.Println(student.Sno, student.Sname, student.Sdate, student.Spassword, student.Samount)

	c.JSON(0, student)
}

//func ShowStudent(re *gin.Engine)  {
//	text := make(map[string]string)
//	text["who"] = "tql"
//	text["sq"] = "tcl"
//	re.POST("/ShowStudent", func(context *gin.Context) {
//		var student Student
//		err := context.BindJSON(&student)
//		if err != nil {
//			log.Fatal(err)
//		}
//		wa, ok := text[student.Sname]
//		if ok {
//			context.JSON(http.StatusOK, gin.H{"ans":wa})
//		} else {
//			context.JSON(http.StatusOK, gin.H{"error":"not found"})
//		}
//	})
//}